﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using WOIM_NET.Annotations;

namespace WOIM_NET.Music
{
    public class DownloadedSongs : INotifyPropertyChanged
    {
        public ObservableCollection<SongModel> DownloadedItems { get; private set; }

        public DownloadedSongs()
        {
            this.DownloadedItems = new ObservableCollection<SongModel>();
        }
        
        public bool IsDataLoaded { get; private set; }

        private int _numberOfSongs;

        public int NumberOfSongs
        {
            get { return _numberOfSongs; }
            set
            {
                if (value == _numberOfSongs) return;
                _numberOfSongs = value;
                OnPropertyChanged();
            }
        }

        public void LoadData()
        {
            this.DownloadedItems.Add(new SongModel(){ Name = "Kiss The Rain", Artist = "Yiruma", Instrumental = "Piano"});
            this.DownloadedItems.Add(new SongModel() { Name = "River Flow In You", Artist = "Yiruma", Instrumental = "Piano" });
            this.DownloadedItems.Add(new SongModel() { Name = "Do You", Artist = "Yiruma", Instrumental = "Piano" });
            this.DownloadedItems.Add(new SongModel() { Name = "When The Love Falls", Artist = "Yiruma", Instrumental = "Piano" });

            this.IsDataLoaded = true;
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
